<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>部门管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/resources/layui/css/layui.css"/>
    <link rel="stylesheet" href="/resources/layui/layui-ext/dtree/dtree.css"/>
    <link rel="stylesheet" href="/resources/layui/layui-ext/dtree/font/dtreefont.css">

</head>

<ul id="deptTree" class="dtree" data-id="0"></ul>

<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/javascript" src="/resources/layui/layui-ext/dtree/dtree.js"></script>
<script type="text/javascript">
    var dtree;
    layui.extend({
        dtree: '/resources/layui/layui-ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
    }).use(['dtree', 'layer', 'jquery'], function () {
         dtree = layui.dtree, layer = layui.layer, $ = layui.jquery;
        var deptTree = dtree.render({
            elem: "#deptTree",
            url: "/dept/loadAllLeftDeptTree",
            method: 'get',
            dataStyle: "layuiStyle",  //使用layui风格的数据格式
            dataFormat: "list",  //配置data的风格为list
            response: {message: "msg", statusCode: 0}  //修改response中返回数据的定义
        });

        dtree.on("node('deptTree')", function (obj) {
            window.parent.main.reloadTable(obj.param.nodeId);
        });


    });
     function reloadTree(){
        dtree.render({
            elem: "#deptTree",
            url: "/dept/loadAllLeftDeptTree",
            method: 'get',
            dataStyle: "layuiStyle",  //使用layui风格的数据格式
            dataFormat: "list",  //配置data的风格为list
            response: {message: "msg", statusCode: 0}  //修改response中返回数据的定义
        });
    }
</script>
</html>